﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace SpeedRun
{
    public partial class RunType : PhoneApplicationPage
    {
        public RunType()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            (App.Current as App).currentRunType = RunTypes.Basic;
            
            NavigationService.Navigate(new Uri("/Runner.xaml",
                 UriKind.RelativeOrAbsolute));
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            (App.Current as App).currentRunType = RunTypes.Time;            
            try
            {
                (App.Current as App).runTime = new TimeSpan(0, int.Parse(timing.Text), 0);
                //(App.Current as App).runTime = new TimeSpan(timePicker.Value.Value.Hour, timePicker.Value.Value.Minute, 0);
            }
            catch (Exception _e)
            {
                MessageBox.Show("Incorrect format of distance");
                return;
            }
            NavigationService.Navigate(new Uri("/Runner.xaml",
                 UriKind.RelativeOrAbsolute));
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            (App.Current as App).currentRunType = RunTypes.Distance;
            try
            {
                (App.Current as App).distTarget = Convert.ToDouble(distance.Text);
            }
            catch(Exception _e)
            {
                MessageBox.Show("Incorrect format of distance");
                return;
            }
            NavigationService.Navigate(new Uri("/Runner.xaml",
                 UriKind.RelativeOrAbsolute));
        }

        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Profile.xaml?id=2",
              UriKind.RelativeOrAbsolute));
        }

        private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Profile.xaml?id=2",
                UriKind.RelativeOrAbsolute));
        }

        private void StackPanel_Loaded(object sender, RoutedEventArgs e)
        {
            basicList.Items.Add(Environment.Indoor);
            basicList.Items.Add(Environment.Indoor);
        }

        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Microsoft.Phone.Tasks.ShareStatusTask share = new Microsoft.Phone.Tasks.ShareStatusTask();
            share.Status = "I am going out for a run! (from : Speed Run for Windows Phone 7)";
            share.Show();
        }
    }
}